<template>
    <div class="goods-list">
        <!-- <div class="goods-item" v-for="item in goodslist" :key="item.id">
            <img :src="item.img_url" alt="">
            <h1 class="title">{{item.title}}</h1>
            <div class="info">
                <p class="price">
                    <span class="now">￥{{item.sell_price}}</span>
                    <span class="old">￥{{item.market_price}}</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩{{item.stock_quantity}}件</span>
                </p>
            </div>
        </div> -->
        
        <!-- <router-link class="goods-item" :to="'/home/goodsinfo/'+this.id" tag="div">
            <img src="https://img12.360buyimg.com/n1/s450x450_jfs/t1/76327/24/7494/166690/5d5a7346E521dde23/c399d644f61cf94b.jpg" alt="">
            <h1 class="title">小米CC9e 索尼4800万旗舰相机  6GB+64GB 智能拍照手机</h1>
            <div class="info">
                <p class="price">
                    <span class="now">1999</span>
                    <span class="old">2199</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </p>

            </div>
        </router-link> -->
        <div class="goods-item" @click="goDetail(id)">
            <img src="https://img12.360buyimg.com/n1/s450x450_jfs/t1/76327/24/7494/166690/5d5a7346E521dde23/c399d644f61cf94b.jpg" alt="">
            <h1 class="title">小米CC9e 索尼4800万旗舰相机  6GB+64GB 智能拍照手机</h1>
            <div class="info">
                <p class="price">
                    <span class="now">1999</span>
                    <span class="old">2199</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </p>

            </div>
        </div>
         <div class="goods-item">
            <img src="https://img12.360buyimg.com/n1/s450x450_jfs/t1/76327/24/7494/166690/5d5a7346E521dde23/c399d644f61cf94b.jpg" alt="">
            <h1 class="title">小米CC9e 索尼4800万旗舰相机  6GB+64GB 智能拍照手机</h1>
            <div class="info">
                <p class="price">
                    <span class="now">1999</span>
                    <span class="old">2199</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </p>

            </div>
        </div>
         <div class="goods-item">
            <img src="https://img12.360buyimg.com/n1/s450x450_jfs/t1/76327/24/7494/166690/5d5a7346E521dde23/c399d644f61cf94b.jpg" alt="">
            <h1 class="title">小米CC9e 索尼4800万旗舰相机  6GB+64GB 游戏智能拍照手机</h1>
            <div class="info">
                <p class="price">
                    <span class="now">1999</span>
                    <span class="old">2199</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </p>

            </div>
        </div>
        <!-- <mt-button type='danger' size='large' @click='getMore'>加载更多</mt-button> -->
        <mt-button type='danger' size='large' >加载更多</mt-button>
    </div>
</template>

<script>
export default {
    data(){
        return {
            // pageindex: 1,
            // goodslist: []
        }
    },
    // created(){
    //     this.getGoodsList()
    // },
    methods:{
        // getGoodsList(){
        //     this.$http.get('api/getgoods?pageindex'+this.pageindex).then(result => {
        //         if(result.body.status === 0){
        //             this.goodslist=this.goodslist.concat(result.body.message)
        //             // this.goodslist = result.body.message
        //         }else{
        //             Toast('获取商品列表数据失败')
        //         }
        //     })
        // },
        // getMore(){
        //     pageindex++;
        //     this.getGoodsList();
        // }
        goDetail(id){
            // 编程式导航
            // this.$router.push("/home/goodsinfo/"+id)
            // 传入对象
            // this.$router.push({path: "/home/goodsinfo/"+id})
            // 命名的路由
            this.$router.push({name: 'goodsinfo',params: { id }})
        }
    }
}
</script>

<style lang="scss" scoped>
.goods-list{
    display: flex;
    flex-wrap: wrap;
    padding: 7px;
    justify-content: space-between;
    .goods-item{
        width: 49%;
        border: 1px solid #ccc;
        box-shadow: 0 0 8px #ccc;
        margin: 4px 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 293px;

        
        img{
            width: 100%;
        }
        .title{
            font-size: 14px;
        }
        .info{
            background-color: #eee;
            p{
                margin: 0;
                padding: 5px;
            }
            .price{
                .now{
                    color: red;
                    font-size: 16px;
                    font-weight: bold;   
                }
                .old{
                    color: #ccc;
                    font-size: 12px;
                    text-decoration: line-through;
                    margin-left: 10px;
                }
            }
            .sell{
                display: flex;
                justify-content: space-between;
                font-size: 12px;
            }
        }
    }
}
</style>